package work20241126_27;

import java.util.Arrays;

/**
 * @author zdl
 * @date 2024/11/26
 */
public class Demo28 {
    public static void main(String[] args) {
        //将一个数组中的重复元素去除，输出去重后的数组。
        int[] arr = {1, 2, 3, 4, 5, 1, 2, 3, 4};
        int len = arr.length;
        for (int i = 0; i < len; i++) {
            for (int j = i+1; j < len; j++) {
                if (arr[i] == arr[j]){
                    arr[j] = arr[len - 1];
                    len--;
                    j--;
                }
            }
        }
        int[] newArr = new int[len];
        for (int i = 0; i < len; i++) {
            newArr[i] = arr[i];
        }
        System.out.println(Arrays.toString(newArr));

    }
}
